﻿namespace FSharpChess
open System
open System.Windows.Forms
open FSharpChess.Funcs
module UI =
    let mnuCopyFEN_Click() =
        // Put FEN position string into the clipboard
        Clipboard.SetDataObject(GetBoardPosition())
    let mnuPasteFEN_Click() =
        // Retrieves the data from the clipboard.
        let itfDataObj = Clipboard.GetDataObject()
        if (itfDataObj.GetDataPresent(DataFormats.Text)) then
            try
                let strFen = (itfDataObj.GetData(DataFormats.Text)).ToString().Trim()
                New(strFen)
            with
                |FENValidationException x -> MessageBox.Show(x)|> ignore
                |x -> MessageBox.Show(x.Message)|> ignore
        else
            MessageBox.Show("Not a FEN summary")|> ignore 
    //used by UI to get index of image
    let imageIndex (c,o) = 
        match (c,o) with
            |(true,enmName.Pawn) -> 9
            |(false,enmName.Pawn) -> 8
            |(true,enmName.Bishop) -> 1
            |(false,enmName.Bishop) -> 0
            |(true,enmName.Knight) -> 7
            |(false,enmName.Knight) -> 6
            |(true,enmName.Rook) -> 3
            |(false,enmName.Rook) -> 2
            |(true,enmName.King) -> 5
            |(false,enmName.King) -> 4
            |(true,enmName.Queen) -> 11
            |(false,enmName.Queen) -> 10
            |_ -> raise InvalidName


